<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@include file="/tf/taglibs.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>

<script type="text/javascript" src="${ctx }/libs/jquery-1.9.0.min.js"></script>
<script src="${ctx}/libs/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script type="text/javascript">
	function is_ok(type) {

		var flag = true;
		$("#stylized input[required='required']").each(function(i) {
			var v = $.trim($(this).val());
			if (v.length <= 0) {
				alert($(this).attr("label") + "不能为空！");
				flag = false;
				return false;
			}
		});
		
		if(flag) {
			
			var args = 'oper=add';
			$("#stylized input[name^='insert_']").each(function(i) {
				var name = $(this).attr("name").split("insert_");
				args +='&'+name[1]+'='+$(this).val();
				//alert(name[1]+"--"+$(this).attr("label")+"--"+$(this).val());
			});
// 			alert(args);
			var url = '${ctx}/operator'+getValueByKey(type)+'/operator.html';
// 			alert(url);
			$.post(url,args, function(data){
				 //回传函数
				 if (data!=undefined&&data.id.length>0) {
			
					 window.location.href="${ctx}/common/deal_listed.action?ordertype=${param.formtype}&id="+data.id;
				 }
				
		   });
			
// 			$("#form").submit();
		}
	}
	
	function getValueByKey(type) {
		
		var v = '';
		$.each(keys, function(key, val) {
			if(val == type) {
				v = entitys[key];
				return v;
			}
		});
		return v;
	}

	var keys = [ "logistics_supply", "logistics_needs", "storage_supply",
			"storage_needs" ];
	var values = [ "物流供应", "物流需求", "仓储供应", "仓储需求" ];
	var entitys = [ "/tlt/TltLsOrder", "/tlt/TltLdOrder",
			"/tlt/TltSsOrder", "/tlt/TltSdOrder" ];
</script>

<link rel="stylesheet" href="${ctx }/tf/css/module.css" type="text/css"/>
</head>
<body>
<h3>订单填写</h3>
<form action="${ctx }/common/deal_listed.action" method="post" id="form">

<div id="stylized" class="myform">

	<input name="ordertype" value="${formtype }" type="hidden"/>
	
	<jsp:include page="/deal/listform/${formtype }.jsp"></jsp:include>
 
 	<p>
 		
<!--  		<input type="submit" value="下一步"/> -->
 	</p>
 	
 	<span class="bottom_button">
 		<input type="button" value="下一步" onclick="is_ok('${param.formtype}')"/>
 	</span>

</div>
</form>

</body>
</html>